package responsibilityChainPattern;

public abstract class Handler {
    protected final static int NUM_ONE=1;
    protected final static int NUM_Three=3;
    protected final static int NUM_Seven=7;

    private int START_NUM=0;
    private int END_NUM=0;

    private Handler nextHandler;

    public Handler(int START_NUM){
        this.START_NUM=START_NUM;
    }
    public Handler(int START_NUM, int END_NUM) {
        this.START_NUM = START_NUM;
        this.END_NUM = END_NUM;
    }

    public void setNextHandler(Handler nextHandler) {
        this.nextHandler = nextHandler;
    }
    public final void submit(Ileave leave){
        if(leave.getNum()==0){
            return;
        }
        if (leave.getNum()>this.START_NUM){
            this.HandlLeave(leave);
            if (this.nextHandler!=null&&leave.getNum()>START_NUM){
                this.nextHandler.submit(leave);
            }
        }
    }
    protected abstract void HandlLeave(Ileave leave);
}
